package tk.winshu.quartz;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.SchedulerException;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author Kevin
 * @since 2019/03/30.
 */
public class PrintJob implements Job {

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss");
        try {
            System.out.println(jobExecutionContext.getScheduler().getSchedulerName() + " : " + formatter.format(LocalDateTime.now()));
        } catch (SchedulerException e) {
            e.printStackTrace();
        }
    }
}
